//base
import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
//less
import './index.less'
import { chooseGender } from '../../../configuration/staticimg'

class ChooseGender extends Component {
  componentWillMount() {
    //onLoad
  }

  componentDidMount() {
    //onready
  }

  componentWillUnmount() {
    //onUnload
  }

  componentWillReceiveProps(nextprops) {}

  onChooseGender = e => {
    let { gender } = e.currentTarget.dataset
    this.props.onChange(gender)
  }

  render() {
    const { title, value = 'male' } = this.props
    return (
      <View className="ChooseGender_id95245">
        <View className="title">{title}</View>
        <View className="content">
          <View className="content-item" onClick={this.onChooseGender} data-gender="male">
            <Image src={chooseGender('male', value === 'male')} />
            <Text className="content-text">男</Text>
          </View>
          <View className="content-item" onClick={this.onChooseGender} data-gender="female">
            <Image src={chooseGender('female', value === 'female')} />
            <Text className="content-text">女</Text>
          </View>
        </View>
      </View>
    )
  }
}

export default ChooseGender
